Function: prependTo(domInsertionElement, domElementOrMarkupStringOrCSSSelector, functionCallback(domElement))
Description: Inserts a target DOM element at the top of an element, markup string, or CSS selector referenced element in the DOM.
Returns: domElement, or $A object if chained.
Note: The prependTo() function is the literal opposite of prepend().
Example:
// Insert a DOM element at the top of another element targetted with a CSS selector
var myElement = $A.prependTo("#myTargetNodeId", domElement);
// Insert a markup string element at the top of another DOM element
var myElement = $A.prependTo(domElement, '
Here we are now, entertain us.
');
// Insert one element referenced by a CSS selector at the top of another DOM element
var myElement = $A.prependTo(domElement, "#myTargetNodeToMove");
// Insert a DOM element at the top of another DOM element and exicute a callback when done
var myElement = $A.prependTo(domElementToTarget, domElementToMove, function(domElementToMove) {
// Do something with domElementToMove after the insertion is complete.
});
// Or the same using chaining
// Insert a DOM element at the top of another element targetted with a CSS selector
var myChain = $A(domElement).prependTo("#myTargetNodeId");
// Insert a markup string element at the top of another DOM element
var myChain = $A('Here we are now, entertain us.
').prependTo(domElement);
// Insert one element referenced by a CSS selector at the top of another DOM element
var myChain = $A("#myTargetNodeToMove").prependTo(domElement);
// Insert a DOM element at the top of another DOM element and exicute a callback when done
var myChain = $A(domElementToMove).prependTo(domElementToTarget, function(domElementToMove) {
// Do something with domElementToMove after the insertion is complete.
});
// To return the modified element within a chain, use the "return()" method.
var myElement = myChain.return();